package com.fot.config;

import com.fot.annotation.RedisMQMessageListenerBeanPostProcessor;
import lombok.NonNull;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanNameGenerator;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;

/**
 * @author 殷豪
 */
@Configuration
@AutoConfigureAfter(RedisMqAutoConfiguration.class)
public class RedisMQListenerConfiguration implements ImportBeanDefinitionRegistrar {
    @Override
    public void registerBeanDefinitions(@NonNull AnnotationMetadata importingClassMetadata, @NonNull BeanDefinitionRegistry registry) {
        if (!registry.containsBeanDefinition(RedisMQMessageListenerBeanPostProcessor.class.getName())) {
            registry.registerBeanDefinition(RedisMQMessageListenerBeanPostProcessor.class.getName(), new RootBeanDefinition(RedisMQMessageListenerBeanPostProcessor.class));
        }
    }
}
